//
//  YSHomeDataTool.m
//  Yueshi
//
//  Created by yueshi_tech on 15/7/15.
//  Copyright (c) 2015年 悦食中国. All rights reserved.
//

#import "YSHomeDataTool.h"

@implementation YSHomeDataTool
+ (void) getHomeInfo:(NSInteger)pageIndex success:(void (^)(YSHomeInfoRes *))success failure:(void (^)(NSError *))failure{
    NSMutableDictionary *params = [NSMutableDictionary dictionaryWithDictionary:[[BaseRequest param] keyValues]];
    if (pageIndex >=0) {
        [params setObject:[NSNumber numberWithInteger:pageIndex] forKey:@"pageIndex"];
    }
    [self postWithUrl:[NSString stringWithFormat:@"%@app/index",BASE_URL] param:params hasT:NO resultClass:[YSHomeInfoRes class] success:success failure:failure];
}

+(void)getHistoryInfo:(NSInteger)pageIndex success:(void (^)(YSHistoryRes *))success failure:(void (^)(NSError *))failure{
    NSMutableDictionary *params = [NSMutableDictionary dictionaryWithDictionary:[[BaseRequest param] keyValues]];
    [params setObject:[NSNumber numberWithInteger:pageIndex] forKey:@"pageIndex"];
    [self postWithUrl:[NSString stringWithFormat:@"%@app/pastIndex",BASE_URL] param:params hasT:NO resultClass:[YSHistoryRes class] success:success failure:failure];
}

+ (void)getReviewsDetailWithId:(NSInteger)reviewsId lastComtId:(NSInteger)lastComtId isLogin:(BOOL)isLogin success:(void (^)(YSReviewsDetailRes *))success failure:(void (^)(NSError *))failure{
    NSMutableDictionary *params = [NSMutableDictionary dictionaryWithDictionary:[[BaseRequest param] keyValues]];
    [params setObject:[NSNumber numberWithInteger:reviewsId] forKey:@"reviewsId"];
    if(lastComtId != 0){
        [params setObject:[NSNumber numberWithInteger:lastComtId] forKey:@"lastComtId"];
    }
    [self postWithUrl:[NSString stringWithFormat:@"%@app/clubDetail",BASE_URL] param:params hasT:isLogin resultClass:[YSReviewsDetailRes class] success:success failure:failure];
}

+ (void)recommentWithReviewsId:(NSInteger)reviewsId commentContent:(NSString *)commentContent targetUserId:(NSInteger)targetUserId success:(void (^)(YSCommentRes *))success failure:(void (^)(NSError *))failure{
    NSMutableDictionary *params = [NSMutableDictionary dictionaryWithDictionary:[[BaseRequest param] keyValues]];
    [params setObject:[NSNumber numberWithInteger:reviewsId] forKey:@"reviewsId"];
    [params setObject:commentContent forKey:@"commentContent"];
    if (targetUserId) {
        [params setObject:[NSNumber numberWithInteger:targetUserId] forKey:@"targetUserId"];
    }
    [self postWithUrl:[NSString stringWithFormat:@"%@club/recomment",BASE_URL] param:params hasT:YES resultClass:[YSCommentRes class] success:success failure:failure];
}

+(void)getSetupInfo:(void (^)(YSSetupInfoRes *))success failure:(void (^)(NSError *))failure{
    NSMutableDictionary *params = [NSMutableDictionary dictionaryWithDictionary:[[BaseRequest param] keyValues]];
    [self postWithUrl:[NSString stringWithFormat:@"%@app/upgrade",BASE_URL] param:params hasT:NO resultClass:[YSSetupInfoRes class] success:success failure:failure];
}

+(void)getContentPoolWithEntityId:(NSString *)entryId success:(void (^)(YSHistoryRes *))success failure:(void (^)(NSError *))failure{
    NSMutableDictionary *params = [NSMutableDictionary dictionaryWithDictionary:[[BaseRequest param] keyValues]];
    [params setObject:entryId forKey:@"entryId"];
    [self postWithUrl:[NSString stringWithFormat:@"%@app/contentsPools",BASE_URL] param:params hasT:NO resultClass:[YSHistoryRes class] success:success failure:failure];
}

+(void)markReviewsWithReviewsId:(NSString *)reviewsId type:(NSInteger)type success:(void (^)(BaseResponse *))success failure:(void (^)(NSError *))failure{
    NSMutableDictionary *params = [NSMutableDictionary dictionaryWithDictionary:[[BaseRequest param] keyValues]];
    [params setObject:reviewsId forKey:@"reviewsId"];
    [params setObject:[NSNumber numberWithInteger:type] forKey:@"type"];
    [self postWithUrl:[NSString stringWithFormat:@"%@club/collect",BASE_URL] param:params hasT:YES resultClass:[BaseResponse class] success:success failure:failure];
}

+(void)getMarkReviewsListWithPageIndex:(NSInteger)pageIndex success:(void(^)(YSReviewsMarkRes *))success failure:(void (^) (NSError *))failure{
    NSMutableDictionary *params = [NSMutableDictionary dictionaryWithDictionary:[[BaseRequest param] keyValues]];
    [params setObject:[NSNumber numberWithInteger:pageIndex] forKey:@"pageIndex"];
    [self postWithUrl:[NSString stringWithFormat:@"%@club/collectList",BASE_URL] param:params hasT:YES resultClass:[YSReviewsMarkRes class] success:success failure:failure];
}

+(void)getMarkProductListWithPageIndex:(NSInteger)pageIndex success:(void (^)(YSProductListRes *))success failure:(void (^)(NSError *))failure{
    NSMutableDictionary *params = [NSMutableDictionary dictionaryWithDictionary:[[BaseRequest param] keyValues]];
    [params setObject:[NSNumber numberWithInteger:pageIndex] forKey:@"pageIndex"];
    [self postWithUrl:[NSString stringWithFormat:@"%@product/mymark",BASE_URL] param:params hasT:YES resultClass:[YSProductListRes class] success:success failure:failure];
}

+(void)getSubscriptWithType:(NSInteger)type success:(void (^)(YSSubscriptModel *))success failure:(void (^)(NSError *))failure{
    NSMutableDictionary *params = [NSMutableDictionary dictionaryWithDictionary:[[BaseRequest param] keyValues]];
    [params setObject:[NSNumber numberWithInteger:type] forKey:@"type"];
    [self postWithUrl:[NSString stringWithFormat:@"%@app/subscript",BASE_URL] param:params hasT:ISLOGIN resultClass:[YSSubscriptModel class] success:success failure:failure];
}

+ (void)getCardMoreWithCardId:(NSInteger)cardId pageIndex:(NSInteger)pageIndex success:(void (^)(YSCardMoreRes *))success failure:(void (^)(NSError *))failure{
    NSMutableDictionary *params = [NSMutableDictionary dictionaryWithDictionary:[[BaseRequest param] keyValues]];
    [params setObject:[NSNumber numberWithInteger:cardId] forKey:@"cardId"];
    [params setObject:[NSNumber numberWithInteger:pageIndex] forKey:@"pageIndex"];
    [self postWithUrl:[NSString stringWithFormat:@"%@app/clubMore",BASE_URL] param:params hasT:NO resultClass:[YSCardMoreRes class] success:success failure:failure];
}

+ (void)getMarkVideoListWithPageIndex:(NSInteger)pageIndex success:(void (^)(YSAdvertRes *))success failure:(void (^)(NSError *))failure{
    NSMutableDictionary *params = [NSMutableDictionary dictionaryWithDictionary:[[BaseRequest param] keyValues]];
    [params setObject:[NSNumber numberWithInteger:pageIndex] forKey:@"pageIndex"];
    [self postWithUrl:[NSString stringWithFormat:@"%@video/markList",BASE_URL] param:params hasT:YES resultClass:[YSAdvertRes class] success:success failure:failure];
}

+ (void)markVideoWithVideoId:(NSString *)videoId type:(NSInteger)type success:(void (^)(BaseResponse *))success failure:(void (^)(NSError *))failure{
    NSMutableDictionary *params = [NSMutableDictionary dictionaryWithDictionary:[[BaseRequest param] keyValues]];
    [params setObject:videoId forKey:@"videoId"];
    [params setObject:[NSNumber numberWithInteger:type] forKey:@"type"];
    [self postWithUrl:[NSString stringWithFormat:@"%@video/collect",BASE_URL] param:params hasT:YES resultClass:[BaseResponse class] success:success failure:failure];
}

+ (void) getVideoDetailsWithAdvertId:(NSInteger)advertId isLogin:(BOOL)isLogin success:(void (^)(YSVideoDetailsRes *))success failure:(void (^)(NSError *))failure{
    NSMutableDictionary *params = [NSMutableDictionary dictionaryWithDictionary:[[BaseRequest param] keyValues]];
    
    [params setObject:[NSNumber numberWithInteger:advertId] forKey:@"advertId"];
    [self postWithUrl:[NSString stringWithFormat:@"%@video/detail",BASE_URL] param:params hasT:isLogin resultClass:[YSVideoDetailsRes class] success:success failure:failure];

}

@end
